#include "widget.h"
#include "ui_widget.h"
#include <QPainter>
#include <QDebug>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
}

Widget::~Widget()
{
    delete ui;
}

void Widget::paintEvent(QPaintEvent *event)
{
    static int i = 0;
    i++;
    qDebug() << i;
    //画线条
    QPainter painter(this);
    painter.drawLine(100,100,200,200);

    QPen pen;
    pen.setColor(Qt::yellow);
    pen.setWidth(10);
    pen.setStyle(Qt::DashLine);
    painter.setPen(pen);

    painter.drawRect(200,200,100,200);

    QBrush brush;
    brush.setStyle(Qt::Dense1Pattern);
    painter.setBrush(brush);
    painter.drawEllipse(0,0,100,200);

    QFont font("微软雅黑",20);
    painter.setFont(font);

    painter.setPen(Qt::red);
    painter.drawText(100,100,"你好世界");

}

